package ${packageName}.${moduleName}.service;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fastrise.frjee.core.model.Page;
import com.fastrise.frjee.core.service.BaseService;
<#if formHead.hisSign != 'true'>
import com.fastrise.frjee.core.utils.UUIDGenerator;
</#if>
import ${packageName}.${moduleName}.dao.${ClassName}Dao;
import ${packageName}.${moduleName}.model.${ClassName};

/**   
 * ${functionName}Service
 * @author ${classAuthor}
 * @version ${classVersion}
 *
 */
@Service(value = "${className}Service")
public class ${ClassName}Service extends BaseService {

	<#if formHead.seqSign == 'true'>
	private static String SEQ = "SEQ_${tableName}";
	</#if>
	
	@Autowired
	private ${ClassName}Dao ${className}Dao;
	
	/**
	 * 分页查询
	 * @param page
	 * @return
	 */
	public Page<${ClassName}> findPage(Page<${ClassName}> page){
		List<${ClassName}> result = ${className}Dao.findPage(page);
		page.setResult(result);
		return page;
	}
	
	/**
	 * 根据ID获取${functionName}
	 * @param id
	 * @return
	 */
	public ${ClassName} get(String id){
		return ${className}Dao.getById(id);
	}
	
	/**
	 * 保存${functionName}
	 * @param ${className}
	 */
	public void save(${ClassName} ${className}){
		<#if formHead.seqSign == 'true'>
		${className}.setId(getSequenceNextIdString(SEQ));
		<#else>
		${className}.setId(UUIDGenerator.generate());
		</#if>
		${className}Dao.save(${className});
	}
	
	/**
	 * 更新${functionName}
	 * @param ${className}
	 */
	public void update(${ClassName} ${className}){
		${className}Dao.update(${className});
	}
	
	/**
	 * 通过ids删除${functionName}
	 * @param ids id数组
	 */
	<#if formHead.hisSign == 'true'>
	public void deleteByIds(String[] ids, String deleteUserId){
		List<String> idList = Arrays.asList(ids);
		${className}Dao.deleteTagByIdList(idList, deleteUserId);
	}
	<#else>
	public void deleteByIds(String[] ids){
		List<String> idList = Arrays.asList(ids);
		${className}Dao.deleteByIdList(idList);
	}
	</#if>
	
}